#include <cstdio>
#include <cstring>

int s[ 16 ], f[ 1 << 16 ];
int p[][ 2 ] = { { 0, 1 }, { 0, 2 }, { 0, 4 }, { 0, 8 }, { 1, 5 }, { 1, 3 }, { 1, 9 }, { 2, 3 }, { 2, 10 }, { 2, 6 },
        { 3, 7 }, { 3, 11 }, { 4, 6 }, { 4, 12 }, { 4, 5 }, { 5, 13 }, { 5, 7 }, { 6, 14 }, { 6, 7 },
        { 7, 15 }, { 8, 12 }, { 8, 9 }, { 8, 10 }, { 9, 13 }, { 9, 11 }, { 10, 11 }, { 10, 14 }, { 11, 15 },
        { 12, 14 }, { 12, 13 }, { 13, 15 }, { 14, 15 } };

void check( int step )
{
    int i, t = 0;
    for ( i = 0; i < 16; i++ )
        t = t * 2 + s[ i ];
    if ( f[ t ] > step )
        f[ t ] = step;
}

void dfs( int step )
{
    int i;
    check( step );
    if ( step < 3 )
    {
        for ( i = 0; i < 32; i++ )
        {
            if ( s[ p[ i ][ 0 ] ] == s[ p[ i ][ 1 ] ] )
                continue;
            s[ p[ i ][ 0 ] ] ^= 1;
            s[ p[ i ][ 1 ] ] ^= 1;
            dfs( step + 1 );
            s[ p[ i ][ 0 ] ] ^= 1;
            s[ p[ i ][ 1 ] ] ^= 1;
        }
    }
}

int main( )
{
    int i, j, t, q, c;
    scanf("%d", &t);
    for ( i = 0; i < 8; i++ )
        s[ i ] = 0;
    for ( i = 8; i < 16; i++ )
        s[ i ] = 1;
    memset( f, 0x3f, sizeof( f ) );
    dfs( 0 );
    for ( i = 1; i <= t; i++ )
    {
        c = 0;
        for ( j = 0; j < 16; j++ )
        {
            scanf("%d", &q);
            c = c * 2 + q;
        }
        printf("Case #%d: ", i);
        if ( f[ c ] > 3 )
            puts("more");
        else
            printf("%d\n", f[ c ]);
    }
    return 0;
}
